package com.sitechasia.webx.components.xtable.cell;

import org.apache.commons.lang.StringUtils;
import org.extremecomponents.table.bean.Column;
import org.extremecomponents.table.cell.Cell;
import org.extremecomponents.table.core.TableModel;
import org.extremecomponents.util.HtmlBuilder;

public class CheckBoxHeaderCell implements Cell {
	public String getExportDisplay(TableModel model, Column column) {
		// return column.getTitle();
		return "";
	}

	/**
	 * 在表头添加checkbox控件
	 */
	public String getHtmlDisplay(TableModel model, Column column) {
		HtmlBuilder html = new HtmlBuilder();
		html.td(2);
		if (StringUtils.isNotEmpty(column.getHeaderClass())) {
			html.styleClass(column.getHeaderClass());
		}
		if (StringUtils.isNotEmpty(column.getHeaderStyle())) {
			html.style(column.getHeaderStyle());
		}
		if (StringUtils.isNotEmpty(column.getWidth())) {
			html.width(column.getWidth());
		}
		html.close();
		html.input("checkbox").id("headerchk");
		// html.input("checkbox");
		html.title("全选/全消");
		if (column.getStyleClass() != null) {
			html.styleClass(column.getStyleClass());
		} else {
			html.styleClass("checkbox");
		}
		html.onclick("checkAll(this)");
		html.xclose();
		html.tdEnd();
		return html.toString();
	}
}
